﻿
<style>
    #NResource_ExpressAddressForm .layui-form-item {
        margin-top: 20px;
        margin-bottom: 0;
    }

        #NResource_ExpressAddressForm .layui-form-item .layui-inline {
            margin-bottom: 25px;
            margin-right: 0;
        }
</style>
<form id="NResource_ExpressAddressForm" lay-filter="NResource_ExpressAddressForm" class="layui-form model-form">
    <div class="layui-form-item btn-detail-opersel">
        <div class="dropdown-menu">
            <button class="layui-btn icon-btn layui-btn-primary" type="button">
                &nbsp;操作<i class="layui-icon layui-icon-drop"></i>
            </button>
            <ul class="dropdown-menu-nav">
                <li id="btn_editNResource_ExpressAddress"><a>编辑</a></li>
                <li id="btn_saveNResource_ExpressAddress" lay-filter="modelSubmitNResource_ExpressAddress" lay-submit><a>保存</a></li>
            </ul>
        </div>
    </div>
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this">基础信息</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="layui-form-item">
                                                                                                                                                                                                                                                                                    <div class="layui-inline  layui-col-md4">
                            <label class="layui-form-label">'CompayName'</label>
                            <div class="layui-input-block">
                                <input required lay-verify="required" id="CompayName" name="CompayName" placeholder="CompayName" type="text" class="layui-input" maxlength="50" />
                            </div>
                        </div>
                                                                                <div class="layui-inline  layui-col-md4">
                            <label class="layui-form-label">'LinkPerson'</label>
                            <div class="layui-input-block">
                                <input required lay-verify="required" id="LinkPerson" name="LinkPerson" placeholder="LinkPerson" type="text" class="layui-input" maxlength="50" />
                            </div>
                        </div>
                                                                                <div class="layui-inline  layui-col-md4">
                            <label class="layui-form-label">'Address'</label>
                            <div class="layui-input-block">
                                <input required lay-verify="required" id="Address" name="Address" placeholder="Address" type="text" class="layui-input" maxlength="50" />
                            </div>
                        </div>
                                                                                <div class="layui-inline  layui-col-md4">
                            <label class="layui-form-label">'LinkMobile'</label>
                            <div class="layui-input-block">
                                <input required lay-verify="required" id="LinkMobile" name="LinkMobile" placeholder="LinkMobile" type="text" class="layui-input" maxlength="50" />
                            </div>
                        </div>
                                     
                </div>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript">
    layui.use(['layer', 'form', 'util', 'admin', 'setter', 'formSelects', 'errorCode', 'laytpl', 'table', 'upload'],async function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var setter = layui.setter;
        var laydate = layui.laydate;
        var util = layui.util;
        var formSelects = layui.formSelects;
        var errorCode = layui.errorCode;
        var laytpl = layui.laytpl;
        var util = layui.util;
        var table = layui.table;
      
        if (setter.getUser() == null)
        {
            location.replace(setter.loginPath);
        }
        var thisindex=this.layer.index;
        var ParentData = admin.getLayerData(thisindex);
        var insTb = ParentData.insTb;
        var treeRender=ParentData.treeRender;
        var seeType=ParentData.seeType;
        var detailModel={};
          var loadindex=layer.load(0);
        var readForm = layui.$('[lay-filter="NResource_ExpressAddressForm"]');
        if(seeType==2)
        {
             await admin.req(setter.SysNResourceService + 'NResource_ExpressAddress/GetDetail', JSON.stringify({ Id: ParentData.Id }), function (res) {
                detailModel=res.data;
            }, 'post')
            // detailModel=ParentData.detailEnt;

             
             readForm.find('input,textarea,select').prop('disabled', true);
             form.render();
             form.val('NResource_ExpressAddressForm', detailModel);
        }
        else if(seeType==1)
        {
            $("#btn_editNResource_ExpressAddress").remove();
            form.render();
        }
        $('#btn_editNResource_ExpressAddress').click(function () {
            readForm.find('input,textarea,select').removeAttr('disabled');
            form.render();
        });
        layer.close(loadindex)
        // 表单提交事件
        form.on('submit(modelSubmitNResource_ExpressAddress)', function (data) {
            layer.load(0);
            if(seeType==1)
            {
                detailModel=data.field;
                detailModel.Id=0;
            }
            else
            {
                for (x in data.field) {
                detailModel[x] = data.field[x];
            }
            }
            
            admin.req(setter.SysNResourceService + 'NResource_ExpressAddress/Save', JSON.stringify({ strEntity: JSON.stringify(detailModel) }), function (res) {
                layer.closeAll('loading');
                layer.msg("保存成功。", { icon: 1 });
                try {
                    insTb.reload({}, 'data');
                    treeRender();
                }
                catch{}
                layer.close(thisindex);
                //form.val('NResource_ExpressAddressForm', res.data);
                //readForm.find('input,textarea,select').attr('disabled', 'disabled');
                //form.render();
            }, 'post');
            return false;
        });

    })
</script>